function [param_names param_table] = get_batch_params(fileDir, varargin)

match_string = ['==========================' char(13) char(10)];

if size(varargin, 2) > 0
    logfilename = optArgs{index};
else
    logfilename = 'logExpParam.txt';
end

param_file = fullfile(fileDir, logfilename);
fid = fopen(param_file);
line_counter = 1;
tline = fgets(fid);
while strcmp(tline, match_string) ~= 1
    if tline == -1
        disp('Reached end of batch file without finding batch parameters')
        break;
    end
    tline = fgets(fid);
    line_counter = line_counter + 1;
end

if tline == -1
    fclose(fid);
    return;
end
batch_start = line_counter;
fclose(fid);

fid = fopen(param_file);
C = textscan(fid, '%s', 1, 'HeaderLines', batch_start, 'EndOfLine', '\n', 'Delimiter', '&');
D = textscan(C{1}{1}, '%s ', 'delimiter', ',', 'EndOfLine', '\r\n');
param_names = strtrim(D{1});
nfields = size(param_names, 1);

E = textscan(fid, '%s', 'HeaderLines', batch_start + 1, 'Delimiter', ',');
M = dlmread(param_file, ',', batch_start + 2, 0);
fclose(fid);

param_table = M;
